﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using Vampirewal.Core;
using Vampirewal.Core.Interface;
using Vampirewal.Core.SimpleMVVM;
using Vampirewal.Core.WPF.Theme;
using Vampirewal.ToolCenter.ViewModel;

namespace Vampirewal.ToolCenter
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : VampirewalApplication
    {
        protected override Type BootStartUp()
        {
            return typeof(BootStartup);
        }

        private IVampirewalCoreDialogMessage Dialog { get; set; }

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            Dialog = VampirewalCoreContext.GetInstance().GetService<IVampirewalCoreDialogMessage>();
        }

        protected override void GlobalExceptions(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            Dialog.ShowPopupWindow(new Core.WindoSetting.PopupWindowSetting()
            {
                Message=e.Exception.Message,
                OwnerWindow=WindowsManager.GetInstance().MainWindow,
                Type= Core.WindoSetting.MessageType.Error
            });

            e.Handled = true;
        }
    }
}
